using System.Collections.Generic;
using System.IO;
using Db4objects.Db4o;
using Db4objects.Db4o.Config;
using FireStarterModeller.BO;
using FireStarterModeller.Logic;
using Habanero.Base;
using Habanero.BO;
using Habanero.DB4O;
using NUnit.Framework;

namespace FireStarterModeller.Test.Logic
{
    [TestFixture]
    [Ignore("Soriya Said that these should be ignored")] //TODO  18 May 2009: Ignored Test - Soriya Said that these should be ignored
    public class TestExportEntityConfiguration
    {
        private bool _updateBOStatusCalled;

        #region Setup/Teardown

        [TestFixtureSetUp]
        public virtual void TestFixtureSetup()
        {
            TestUtils.SetupFixture();
        }

        [SetUp]
        public virtual void SetupTest()
        {
            const string sourceFile = @"..\..\BaseTestData\FireStarterModeller.db4o";
            Db4oFactory.Configure().ObjectClass(typeof (BusinessObjectDTO)).CascadeOnUpdate(true);
            Db4oFactory.Configure().OptimizeNativeQueries(true);
            Db4oFactory.Configure().Queries().EvaluationMode(QueryEvaluationMode.Immediate);
            Db4oFactory.Configure().ObjectClass(typeof(BusinessObjectDTO)).ObjectField("ClassDefName").Indexed(true);
            Db4oFactory.Configure().ObjectClass(typeof(BusinessObjectDTO)).ObjectField("ID").Indexed(true);
            IObjectContainer container = Db4oFactory.OpenFile(sourceFile);

            DB4ORegistry.DB = container;
            BORegistry.DataAccessor = new DataAccessorDB4O(DB4ORegistry.DB);
        }

        [TearDown]
        public virtual void TearDownTest()
        {
            DB4ORegistry.DB.Close();
        }

        #endregion

        [Test]
        public void Test_ExportEntityConfiguration_FileDoesNotExist()
        {
            //---------------Set up test pack-------------------
            DB4ORegistry.DB.Close();
            const string copyFile = @"..\..\CopiedTestData\FireStarterModeller.db4o";
            const string sourceFile = @"..\..\BaseTestData\FireStarterModeller.db4o";
            //---------------Assert Precondition----------------
            Assert.IsFalse(File.Exists(copyFile));
            //---------------Execute Test ----------------------
            File.Copy(sourceFile, copyFile);
            //---------------Test Result -----------------------
            Assert.IsTrue(File.Exists(copyFile));
            File.Delete(copyFile);
        }

        [Test]
        public void Test_ExportEntityConfiguration_FileExists_SolutionDoesNotExist()
        {
            DMSolution solution = TestUtilsShared.CreateSavedDMSolution();

            //---------------Assert Precondition----------------
            Assert.IsNotNull(solution);
            MultipleRelationship<DMAssembly> moduleRelationship =
                (MultipleRelationship<DMAssembly>) solution.Relationships["Modules"];
            Assert.AreEqual(1, moduleRelationship.CurrentBusinessObjectCollection.Count);
            //---------------Execute Test ----------------------
            ConfigurationExporter configurationExporter = new ConfigurationExporter();
            configurationExporter.ExportSolution(solution, false);
            //---------------Test Result -----------------------
            DMSolution loadSolutionFromCopyAfterSave = Broker.GetBusinessObject<DMSolution>
                ("SolutionName='" + solution.SolutionName + "'");
            Assert.IsNotNull(loadSolutionFromCopyAfterSave);
            Assert.AreEqual(1, loadSolutionFromCopyAfterSave.Modules.Count);
        }

        [Test]
        public void Test_ExportEntityConfiguration_FileExists_SolutionDoesExist()
        {
            //---------------Set up test pack-------------------
            DMSolution solution = Broker.GetBusinessObject<DMSolution>("SolutionName='A3162290'");
            BusinessObjectCollection<DMPropertyType> propertyTypes = solution.PropertyTypes;
            int noPropertyTypes = propertyTypes.Count;
            //---------------Assert Precondition----------------
            Assert.IsNotNull(solution);
            //---------------Set up test pack-------------------
            DMAssembly dmAssembly = TestUtilsShared.CreateDMAssembly(solution);
            solution.SolutionDescription = TestUtilsShared.GetRandomString();
            solution.Save();
            int expected = solution.Modules.Count;
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            ConfigurationExporter configurationExporter = new ConfigurationExporter();
            configurationExporter.ExportSolution(solution, false);
            //---------------Test Result -----------------------
            DMSolution loadSolutionFromCopyAfterSave = Broker.GetBusinessObject<DMSolution>
                ("SolutionName='" + solution.SolutionName + "'");
            Assert.IsNotNull(loadSolutionFromCopyAfterSave);
            BusinessObjectCollection<DMAssembly> assemblies = loadSolutionFromCopyAfterSave.Modules;
            Assert.IsTrue(assemblies.Contains(dmAssembly));
            Assert.AreEqual(solution.SolutionDescription, loadSolutionFromCopyAfterSave.SolutionDescription);
            Assert.AreEqual(expected, assemblies.Count);
            Assert.AreEqual(noPropertyTypes, loadSolutionFromCopyAfterSave.PropertyTypes.Count);
        }

        [Test]
        public void Test_ExportEntityConfiguration_FileExists_SolutionWithEntityDoesNotExist()
        {
            //---------------Set up test pack-------------------
            DMSolution solution = TestUtilsShared.CreateSavedDMSolution();
            DMClass dmClass = TestUtilsDMClass.CreateSavedDMClass(solution);
            DMProperty objectIdentityProp = TestUtilsShared.CreateSavedDMProperty(dmClass);
            DMProperty ucProp = TestUtilsShared.CreateSavedDMProperty(dmClass);
            dmClass.CreateObjectIdentity(objectIdentityProp);
            IList<DMProperty> props = new List<DMProperty> {ucProp};
            dmClass.CreateUnsavedUniqueConstraint(props);
            dmClass.Save();
            //---------------Assert Precondition----------------
            Assert.IsNotNull(solution);
            DMAssembly assembly = solution.DefaultAssembly;
            BusinessObjectCollection<DMClass> entities = assembly.Entities;
            Assert.AreEqual(1, entities.Count);
            Assert.AreEqual(2, entities[0].Properties.Count);
            //---------------Execute Test ----------------------
            ConfigurationExporter configurationExporter = new ConfigurationExporter();
            configurationExporter.ExportSolution(solution, false);

            //---------------Test Result -----------------------
            string solutionName = solution.SolutionName;
            DMSolution loadSolutionFromCopyAfterSave = Broker.GetBusinessObject<DMSolution>
                ("SolutionName='" + solutionName + "'");
            Assert.IsNotNull(loadSolutionFromCopyAfterSave);
            BusinessObjectCollection<DMAssembly> assemblies = loadSolutionFromCopyAfterSave.Modules;
            Assert.AreEqual(1, assemblies.Count);
            BusinessObjectCollection<DMClass> classes = assemblies[0].Entities;
            Assert.AreEqual(1, classes.Count);

            DMClass classAfterSave = classes[0];
            Assert.IsTrue(classAfterSave.Generated.Value);
            BusinessObjectCollection<DMProperty> dmProperties = classAfterSave.Properties;
            Assert.AreEqual(2, dmProperties.Count);
            foreach (DMProperty property in dmProperties)
            {
                Assert.IsTrue(property.Generated.Value);
            }
            DMObjectIdentity objectIdentity = classAfterSave.ObjectIdentity;
            Assert.IsTrue(objectIdentity.Generated.Value);
            Assert.AreEqual(1, objectIdentity.Properties.Count);
            Assert.AreEqual(1, classAfterSave.UniqueConstraints.Count);
            Assert.AreEqual(1, classAfterSave.UniqueConstraints[0].UniqueConstraintProperties.Count);
            DB4ORegistry.DB.Close();
            const string sourceFile = @"..\..\BaseTestData\FireStarterModeller.db4o";
            Db4oFactory.Configure().ObjectClass(typeof (BusinessObjectDTO)).CascadeOnUpdate(true);
            DB4ORegistry.DB = Db4oFactory.OpenFile(sourceFile);
            BORegistry.DataAccessor = new DataAccessorDB4O(DB4ORegistry.DB);
            BusinessObjectManager.Instance.ClearLoadedObjects();
            DMSolution loadedSolution = Broker.GetBusinessObject<DMSolution>("SolutionName='" + solutionName + "'");
            Assert.IsNotNull(loadedSolution);
            loadedSolution.DefaultAssembly.Entities.Refresh();
            foreach (DMClass dmClass1 in assembly.Entities)
            {
                Assert.IsTrue(dmClass1.Generated.Value);
            }
        }

        //[Test]
        //public void Test_ExportEntityConfiguration_FileExists_SolutionWithEntityDoesExist()
        //{
        //    //---------------Set up test pack-------------------
        //    DMSolution solution = TestUtilsShared.CreateSavedDMSolution();
        //    DMClass dmClass = TestUtilsDMClass.CreateSavedDMClass(solution);
        //    DMProperty objectIdentityProp = TestUtilsShared.CreateSavedDMProperty(dmClass);
        //    DMProperty ucProp = TestUtilsShared.CreateSavedDMProperty(dmClass);
        //    dmClass.CreateObjectIdentity(objectIdentityProp);
        //    IList<DMProperty> props = new List<DMProperty> {ucProp};
        //    dmClass.CreateUnsavedUniqueConstraint(props);
        //    dmClass.Save();
        //    //---------------Assert Precondition----------------
        //    Assert.IsNotNull(solution);
        //    DMAssembly assembly = solution.DefaultAssembly;
        //    BusinessObjectCollection<DMClass> entities = assembly.Entities;
        //    Assert.AreEqual(1, entities.Count);
        //    Assert.AreEqual(2, entities[0].Properties.Count);
        //    //---------------Execute Test ----------------------
        //    ConfigurationExporter configurationExporter = new ConfigurationExporter();
        //    configurationExporter.ExportSolution(solution);

        //    //---------------Test Result -----------------------
        //    DMSolution loadSolutionFromCopyAfterSave =
        //        Broker.GetBusinessObject<DMSolution>("SolutionName='" + solution.SolutionName + "'");
        //    Assert.IsNotNull(loadSolutionFromCopyAfterSave);
        //    BusinessObjectCollection<DMAssembly> assemblies = loadSolutionFromCopyAfterSave.Modules;
        //    Assert.AreEqual(2, assemblies.Count);
        //    BusinessObjectCollection<DMClass> classes = assemblies[0].Entities;
        //    Assert.AreEqual(1, classes.Count);

        //    DMClass classAfterSave = classes[0];
        //    Assert.IsTrue(classAfterSave.Generated.Value);
        //    BusinessObjectCollection<DMProperty> dmProperties = classAfterSave.Properties;
        //    Assert.AreEqual(2, dmProperties.Count);
        //    foreach (DMProperty property in dmProperties)
        //    {
        //        Assert.IsTrue(property.Generated.Value);
        //    }
        //    DMObjectIdentity objectIdentity = classAfterSave.ObjectIdentity;
        //    Assert.IsTrue(objectIdentity.Generated.Value);
        //    Assert.AreEqual(1, objectIdentity.Properties.Count);
        //    Assert.AreEqual(1, classAfterSave.UniqueConstraints.Count);
        //    Assert.AreEqual(1, classAfterSave.UniqueConstraints[0].UniqueConstraintProperties.Count);
        //}

        [Test]
        public void Test_ExportEntityConfiguration_FileExists_SolutionWithRelationshipDoesNotExist()
        {
            //---------------Set up test pack-------------------
            DMClass dmClass = TestUtilsShared.CreateSavedDMClassWithRelationships();
            DMSolution solution = dmClass.Solution;
            //---------------Assert Precondition----------------
            Assert.IsNotNull(solution);
            Assert.AreEqual(2, dmClass.OwnerRelationships.Count);
            Assert.AreEqual(0, dmClass.RelatedRelationships.Count);
            //---------------Execute Test ----------------------
            ConfigurationExporter configurationExporter = new ConfigurationExporter();
            configurationExporter.ExportSolution(solution, false);

            //---------------Test Result -----------------------
            DMSolution loadSolutionFromCopyAfterSave = Broker.GetBusinessObject<DMSolution>
                ("SolutionName='" + solution.SolutionName + "'");
            Assert.IsNotNull(loadSolutionFromCopyAfterSave);
            BusinessObjectCollection<DMAssembly> assemblies = loadSolutionFromCopyAfterSave.Modules;
            BusinessObjectCollection<DMClass> classes = assemblies[0].Entities;
            Assert.AreEqual(3, classes.Count);
            DMClass classWithRelationships = classes.Find(@class => @class.ClassNameBO == dmClass.ClassNameBO);
            Assert.AreEqual(2, classWithRelationships.OwnerRelationships.Count);
        }

        [Test]
        public void Test_ExportEntityConfiguration_FileExists_SolutionWithRelationshipDoesExist()
        {
            //---------------Set up test pack-------------------
            DMSolution solution = Broker.GetBusinessObject<DMSolution>("SolutionName='A20823733'");
            Assert.IsNotNull(solution);
            DMClass dmClass = solution.AllClasses.Find(@class => @class.ClassNameBO == "A10620");
            //---------------Assert Precondition----------------
            Assert.IsNotNull(solution);
            BusinessObjectCollection<DMRelationship> relationships = dmClass.OwnerRelationships;
            Assert.AreEqual(2, relationships.Count);
            Assert.AreEqual(0, dmClass.RelatedRelationships.Count);
            //---------------Pre-Execute Test ----------------------
            DMRelationship relationship = relationships[0];
            relationship.RelationshipDescription = TestUtilsShared.GetRandomString();
            relationship.KeepReference = true;
            solution.Save();
            //---------------Assert Pre Conditions--------------
            Assert.IsTrue(relationship.KeepReference.Value);
            //--------------------Execute Test -----------------
            ConfigurationExporter configurationExporter = new ConfigurationExporter();
            configurationExporter.ExportSolution(solution, false);

            //---------------Test Result -----------------------
            string solutionName = solution.SolutionName;
            DMSolution loadSolutionFromCopyAfterSave = Broker.GetBusinessObject<DMSolution>
                ("SolutionName='" + solutionName + "'");
            Assert.IsNotNull(loadSolutionFromCopyAfterSave);
            DMClass loadedClassFromExport = solution.AllClasses.Find(@class => @class.ClassNameBO == "A10620");
            BusinessObjectCollection<DMRelationship> loadRelationshipsAfterExport =
                loadedClassFromExport.OwnerRelationships;
            Assert.AreEqual(2, loadRelationshipsAfterExport.Count);
            DMRelationship editedRelationshipFromExport = loadRelationshipsAfterExport.Find
                (dmRelationship => dmRelationship.RelationshipName == relationship.RelationshipName);
            Assert.IsNotNull(editedRelationshipFromExport);
            Assert.AreEqual(relationship.RelationshipDescription, editedRelationshipFromExport.RelationshipDescription);
            Assert.IsTrue(editedRelationshipFromExport.KeepReference.Value);
            DB4ORegistry.DB.Close();
            const string sourceFile = @"..\..\BaseTestData\FireStarterModeller.db4o";
            Db4oFactory.Configure().ObjectClass(typeof (BusinessObjectDTO)).CascadeOnUpdate(true);
            DB4ORegistry.DB = Db4oFactory.OpenFile(sourceFile);
            BORegistry.DataAccessor = new DataAccessorDB4O(DB4ORegistry.DB);
            BusinessObjectManager.Instance.ClearLoadedObjects();
            DMSolution loadedSolution = Broker.GetBusinessObject<DMSolution>("SolutionName='" + solutionName + "'");
            Assert.IsNotNull(loadedSolution);
            DMClass loadedClass = solution.AllClasses.Find(@class => @class.ClassNameBO == "A10620");
            Assert.IsTrue(loadedClass.Generated.Value);
        }

        [Test]
        public void Test_ExportEntityConfiguration_FileExists_SolutionWithUIViewDoesNotExist()
        {
            //---------------Set up test pack-------------------
            DMClass dmClass = TestUtilsShared.CreateSavedDMClassWithUIInfo_GridAndForm();
            DMSolution solution = dmClass.Solution;
            //---------------Assert Precondition----------------
            Assert.IsNotNull(solution);
            Assert.AreEqual(1, dmClass.UIViews.Count);
            UIView uiView = dmClass.UIViews[0];
            Assert.IsNotNull(uiView.UIGridInfo);
            Assert.IsNotNull(uiView.UIFormInfo);
            //---------------Execute Test ----------------------
            ConfigurationExporter configurationExporter = new ConfigurationExporter();
            configurationExporter.ExportSolution(solution, false);

            //---------------Test Result -----------------------
            DMSolution loadSolutionFromCopyAfterSave = Broker.GetBusinessObject<DMSolution>
                ("SolutionName='" + solution.SolutionName + "'");
            Assert.IsNotNull(loadSolutionFromCopyAfterSave);
            BusinessObjectCollection<DMAssembly> assemblies = loadSolutionFromCopyAfterSave.Modules;
            BusinessObjectCollection<DMClass> classes = assemblies[0].Entities;
            Assert.AreEqual(1, classes.Count);
            DMClass classWithUIView = classes.Find(@class => @class.ClassNameBO == dmClass.ClassNameBO);
            Assert.AreEqual(1, classWithUIView.UIViews.Count);
            UIView uiViewSaved = classWithUIView.UIViews[0];
            Assert.IsNotNull(uiViewSaved.UIGridInfo);
            Assert.IsNotNull(uiViewSaved.UIFormInfo);
        }

        [Test]
        public void Test_ExportEntityConfiguration_FileExists_SolutionWithUIViewDoesExist()
        {
            //---------------Set up test pack-------------------
            DMSolution solution = Broker.GetBusinessObject<DMSolution>("SolutionName='A5788244'");
            DMClass dmClass = solution.AllClasses.Find(@class => @class.ClassNameBO == "A45038");
            //---------------Assert Precondition----------------
            Assert.IsNotNull(solution);
            Assert.IsNotNull(dmClass);
            Assert.AreEqual(1, dmClass.UIViews.Count);
            UIView uiView = dmClass.UIViews[0];
            Assert.IsNotNull(uiView.UIGridInfo);
            Assert.IsNotNull(uiView.UIFormInfo);
            //------------------Pre-Execute Test----------------
            uiView.ViewName = TestUtilsShared.GetRandomString();
            solution.Save();
            //---------------Execute Test ----------------------
            ConfigurationExporter configurationExporter = new ConfigurationExporter();
            configurationExporter.ExportSolution(solution, false);

            //---------------Test Result -----------------------
            DMSolution loadSolutionFromCopyAfterSave = Broker.GetBusinessObject<DMSolution>
                ("SolutionName='" + solution.SolutionName + "'");
            DMClass loadedClassAfterExport = solution.AllClasses.Find
                (@class => @class.ClassNameBO == dmClass.ClassNameBO);
            Assert.IsNotNull(loadSolutionFromCopyAfterSave);
            Assert.IsNotNull(loadedClassAfterExport);
            Assert.AreEqual(1, loadedClassAfterExport.UIViews.Count);
            UIView uiViewSaved = loadedClassAfterExport.UIViews[0];
            Assert.IsNotNull(uiViewSaved.UIGridInfo);
            Assert.IsNotNull(uiViewSaved.UIFormInfo);
            Assert.AreEqual(uiView.ViewName, uiViewSaved.ViewName);
        }

        [Test]
        public void Test__UpdateSolutionStatusUsingCustomDelegate_ShouldCallDelegate()
        {
            //--------------- Set up test pack ------------------
            DMSolution solution = new DMSolution();
            solution.SolutionName = TestUtilsShared.GetRandomString(2, 8);
            solution.SolutionDirectory = TestUtilsShared.GetRandomString();
            ConfigurationExporter exporter = new ConfigurationExporter();
            _updateBOStatusCalled = false;
            //--------------- Test Preconditions ----------------
            Assert.IsNotNull(solution);
            Assert.IsFalse(_updateBOStatusCalled);
            //--------------- Execute Test ----------------------
            exporter.UpdateBOStatus(solution, UpdateBOStatusStub);
            //--------------- Test Result -----------------------
            Assert.IsTrue(_updateBOStatusCalled);
        }

        [Test]
        public void Test__UpdateSolutionStatusUsingCustomDelegate_ShouldCallDelegate_UpdatingGeneratedProp()
        {
            //--------------- Set up test pack ------------------
            DMSolution solution = new DMSolution();
            solution.SolutionName = TestUtilsShared.GetRandomString(2, 8);
            solution.SolutionDirectory = TestUtilsShared.GetRandomString();
            DMAssembly assembly = TestUtilsShared.CreateUnsavedValidProjectAssemblyInfo(solution);
            solution.DefaultAssembly = assembly;
            solution.Generated = true;
            solution.Save();
            IBOProp generatedProp = solution.Props["Generated"];
            ConfigurationExporter exporter = new ConfigurationExporter();
            //--------------- Test Preconditions ----------------
            Assert.IsNotNull(solution);
            Assert.IsFalse(solution.Status.IsNew);
            Assert.IsFalse(solution.Status.IsDirty);
            Assert.IsTrue(solution.Generated.Value);
            Assert.IsFalse(generatedProp.IsDirty);
            //--------------- Execute Test ----------------------
            exporter.UpdateBOStatus(solution, ConfigurationExporter.UpdateBOAndGeneratedPropToDirty);
            //--------------- Test Result -----------------------
            Assert.IsFalse(solution.Status.IsNew);
            Assert.IsTrue(solution.Status.IsDirty);
            Assert.IsTrue(solution.Generated.Value);
            Assert.IsTrue(generatedProp.IsDirty);
        }

//        UIBOEditorCreator boEditorCreator = new UIBOEditorCreator();
//        UIFormInfo uiFormInfo = boEditorCreator.CreateBOEditor(this.Class);
                       
        [Test]
        public void Test_ExportSolution_UpdatesUIForm()
        {
            //---------------Set up test pack-------------------
            BORegistry.DataAccessor = new DataAccessorInMemory();
            DMClass dmClass = TestUtilsShared.CreateSavedDMClassWithUIInfo_GridAndForm();
            DMProperty property = TestUtilsDMProperty.CreateUnsavedValidDMProperty(dmClass);
            UIBOEditorCreator boEditorCreator = new UIBOEditorCreator();
            UIView view = dmClass.UIViews[0];
            UIFormInfo info = view.UIFormInfo;
            info.MarkForDelete();
            view.UIFormInfo = boEditorCreator.CreateBOEditor(dmClass);
             ITransactionCommitter committer = BORegistry.DataAccessor.CreateTransactionCommitter();
            committer.AddBusinessObject(info);
            committer.AddBusinessObject(dmClass);
            committer.CommitTransaction();
            ConfigurationExporter exporter = new ConfigurationExporter();
            //---------------Assert Precondition----------------
            Assert.AreEqual(1, dmClass.Properties.Count);
            Assert.AreEqual(1, view.UIFormInfo.UIFields.Count);
//            Assert.IsNotNull(dmClass.ObjectIdentity);
            //---------------Execute Test ----------------------
            DMProperty newProp = TestUtilsDMProperty.CreateUnsavedValidDMProperty(dmClass);
            newProp.Save();
            exporter.ExportSolution(dmClass.Solution, false);
            //---------------Test Result -----------------------
            Assert.AreEqual(2, dmClass.Properties.Count);
            Assert.AreEqual(2, view.UIFormInfo.UIFields.Count);
            
        }

        [Test]
        public void Test_CreateUIFormInfoForDMClass_ShouldCreateWithAppropriateProperties_AndDeletePreviousFormInfo()
        {
            //---------------Set up test pack-------------------
            BORegistry.DataAccessor = new DataAccessorInMemory();
            DMClass dmClass = TestUtilsShared.CreateSavedDMClassWithUIInfo_GridAndForm();
            DMProperty property = TestUtilsDMProperty.CreateUnsavedValidDMProperty(dmClass);
            dmClass.Save();
            ConfigurationExporter exporter = new ConfigurationExporter();
            UIView view = dmClass.UIViews[0];
            UIFormInfo formInfo = view.UIFormInfo;
            //---------------Assert Precondition----------------
            Assert.IsNotNull(view);
            Assert.IsNotNull(formInfo);
            Assert.AreEqual(0, formInfo.UIFields.Count);
            //---------------Execute Test ----------------------
            exporter.CreateNewUIForm(dmClass);
            //---------------Test Result -----------------------
            UIFormInfo newFormInfo = view.UIFormInfo;
            Assert.IsFalse(newFormInfo.Status.IsNew);
            Assert.IsFalse(newFormInfo.Status.IsDirty);
            Assert.AreNotSame(formInfo, newFormInfo);
            Assert.AreEqual(1, newFormInfo.UIFields.Count);
            //Verify Previous One Deleted
            Assert.IsTrue(formInfo.Status.IsDeleted);
            Assert.IsTrue(formInfo.Status.IsNew);
        }

//        private void UpdateBOAndGeneratedPropToDirty(IBusinessObject businessObject)
//        {
//            if (businessObject != null)
//            {
////                BOStatus boStatus = (BOStatus)businessObject.Status;
////                ReflectionUtilities.SetPropertyValue(boStatus, "IsDirty", true);
//                if (businessObject.Props.Contains("Generated"))
//                {
//                    IBOProp generatedProp = businessObject.Props["Generated"];
//                    generatedProp.Value = false;
//                    generatedProp.BackupPropValue();
//                    generatedProp.Value = true;
//                }
//
//            }
//        }

        private void UpdateBOStatusStub(IBusinessObject solution)
        {
            _updateBOStatusCalled = true;
        }
    }
}